package com.leolian.spring02.transaction.demo3;

import javax.annotation.Resource;

import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

/**
 * @author Lian
 * DAO 实现类
 */
@Repository("accountDao")
public class AccountDaoImpl implements AccountDao {
	
	@Resource
	private JdbcTemplate jdbcTemplate;
	
	public void decrMoney(String out, Double money) {
		String sql = "UPDATE account SET money=money-? WHERE `name`=?";
		jdbcTemplate.update(sql, money, out);
	}

	public void incrMoney(String in, Double money) {
		String sql = "UPDATE account SET money=money+? WHERE `name`=?";
		jdbcTemplate.update(sql, money, in);
	}

}
